<?php
    global $_GPC, $_W;
    $rid = intval($_GPC['rid']);

    $uniacid = $_W['uniacid'];

    $reply = pdo_fetch( " SELECT * FROM ".tablename('haoman_dpm_countmoneyreply')." WHERE rid='".$rid."' " );

    if(empty($reply)){
        $data = array(
            'ResultType' => 2,
            'Message' => "活动不存在"
        );
        echo json_encode($data);
    }elseif ($reply['iscount']!=1){
        $data = array(
            'ResultType' => 2,
            'Message' => "数钱活动未开启"
        );
        echo json_encode($data);
    }


        $Counts = pdo_fetchall("SELECT * FROM " . tablename('haoman_dpm_countmoneyuser') . " WHERE pici = :pici and  rid = :rid and uniacid=:uniacid and `count`>0 order by `count` desc limit 13",array(':rid'=>$rid,':uniacid'=>$uniacid,':pici'=>$reply['pici']));

        if(count($Counts)>1){
            $data = array(
                'ResultType' => 3,
                'Message' => '活动已经结束',
                'data' =>$Counts,
                'IsOver' =>true,
            );
            echo json_encode($data);
            exit;
        }

    $AppendData = array(
        'id' => $reply['pici'],
        'Duration' => $reply['countmoney_time'],
        'Duration2' => $reply['countmoney_time']*10
    );

    $data = array(
        'ResultType' => 1,
        'Message' => "数钱记录不存在",
        'LogMessage' => '',
        "AppendData"=> $AppendData
    );


    echo json_encode($data);